﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Schema;


using Simhopp.Common;

using System.Runtime.Serialization.Formatters.Binary;

namespace Simhopp.Client
{
    class Client
    {
        private ClientListener listener;

        public void printToScreen(Object o)
        {
            Console.WriteLine(o.ToString());
        }


        public Client(Action<Object> callBack)
        {
            try
            {
                TcpClient tcpclnt = new TcpClient();
                
                Console.WriteLine("Connecting.....");

                tcpclnt.Connect("127.0.0.1", 123);
                // use the ipaddress as in the server program

                listener = new ClientListener(tcpclnt, callBack);
                
            }

            catch (Exception e)
                {
                }

        }

        public void sendObject(NetworkCommand o)
        {
            listener.SendObject(o);
            }

        public void stop()
            {
            listener.stop();
            }


        internal EndPoint getEndPoint()
        {
            return listener.getEndPoint();
        }
    }
}
